﻿#region Using directives

using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Indeco.G24.Entities;
using Indeco.G24.Data;

#endregion

namespace Indeco.G24.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="ViewBangGiaSanPhamProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract class ViewBangGiaSanPhamProviderBaseCore : EntityViewProviderBase<ViewBangGiaSanPham>
	{
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions
		
		/*
		///<summary>
		/// Fill an VList&lt;ViewBangGiaSanPham&gt; From a DataSet
		///</summary>
		/// <param name="dataSet">the DataSet</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList&lt;ViewBangGiaSanPham&gt;"/></returns>
		protected static VList&lt;ViewBangGiaSanPham&gt; Fill(DataSet dataSet, VList<ViewBangGiaSanPham> rows, int start, int pagelen)
		{
			if (dataSet.Tables.Count == 1)
			{
				return Fill(dataSet.Tables[0], rows, start, pagelen);
			}
			else
			{
				return new VList<ViewBangGiaSanPham>();
			}	
		}
		
		
		///<summary>
		/// Fill an VList&lt;ViewBangGiaSanPham&gt; From a DataTable
		///</summary>
		/// <param name="dataTable">the DataTable that hold the data.</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList<ViewBangGiaSanPham>"/></returns>
		protected static VList&lt;ViewBangGiaSanPham&gt; Fill(DataTable dataTable, VList<ViewBangGiaSanPham> rows, int start, int pagelen)
		{
			int recordnum = 0;
			
			System.Collections.IEnumerator dataRows =  dataTable.Rows.GetEnumerator();
			
			while (dataRows.MoveNext() && (pagelen != 0))
			{
				if(recordnum >= start)
				{
					DataRow row = (DataRow)dataRows.Current;
				
					ViewBangGiaSanPham c = new ViewBangGiaSanPham();
					c.IDSanPham = (Convert.IsDBNull(row["ID_SanPham"]))?Guid.Empty:(System.Guid)row["ID_SanPham"];
					c.IDNhaCungCap = (Convert.IsDBNull(row["ID_NhaCungCap"]))?Guid.Empty:(System.Guid)row["ID_NhaCungCap"];
					c.IDDiaBan = (Convert.IsDBNull(row["ID_DiaBan"]))?Guid.Empty:(System.Guid)row["ID_DiaBan"];
					c.KichHoat = (Convert.IsDBNull(row["KichHoat"]))?false:(System.Boolean)row["KichHoat"];
					c.ChungThuc = (Convert.IsDBNull(row["ChungThuc"]))?false:(System.Boolean)row["ChungThuc"];
					c.TrangThai = (Convert.IsDBNull(row["TrangThai"]))?false:(System.Boolean)row["TrangThai"];
					c.ChoNhapGia = (Convert.IsDBNull(row["ChoNhapGia"]))?false:(System.Boolean)row["ChoNhapGia"];
					c.DonGia = (Convert.IsDBNull(row["DonGia"]))?0:(System.Decimal)row["DonGia"];
					c.VAT = (Convert.IsDBNull(row["VAT"]))?0.0f:(System.Double)row["VAT"];
					c.SoLuongTrongKho = (Convert.IsDBNull(row["SoLuongTrongKho"]))?(long)0:(System.Int64?)row["SoLuongTrongKho"];
					c.TieuChuanKyThuat = (Convert.IsDBNull(row["TieuChuanKyThuat"]))?string.Empty:(System.String)row["TieuChuanKyThuat"];
					c.Thongtinthem = (Convert.IsDBNull(row["Thongtinthem"]))?string.Empty:(System.String)row["Thongtinthem"];
					c.ThoiDiemDangBaoGia = (Convert.IsDBNull(row["ThoiDiemDangBaoGia"]))?DateTime.MinValue:(System.DateTime)row["ThoiDiemDangBaoGia"];
					c.ThoiDiemHetHieuLuc = (Convert.IsDBNull(row["ThoiDiemHetHieuLuc"]))?DateTime.MinValue:(System.DateTime)row["ThoiDiemHetHieuLuc"];
					c.NgoaiTe = (Convert.IsDBNull(row["NgoaiTe"]))?string.Empty:(System.String)row["NgoaiTe"];
					c.TenNgoaiTe = (Convert.IsDBNull(row["TenNgoaiTe"]))?string.Empty:(System.String)row["TenNgoaiTe"];
					c.TyGia = (Convert.IsDBNull(row["TyGia"]))?0.0f:(System.Double)row["TyGia"];
					c.MaDiaBan = (Convert.IsDBNull(row["MaDiaBan"]))?string.Empty:(System.String)row["MaDiaBan"];
					c.NhaCungCap = (Convert.IsDBNull(row["NhaCungCap"]))?string.Empty:(System.String)row["NhaCungCap"];
					c.TenNhaCungCap = (Convert.IsDBNull(row["TenNhaCungCap"]))?string.Empty:(System.String)row["TenNhaCungCap"];
					c.IDSanPhamDanhMuc = (Convert.IsDBNull(row["ID_SanPhamDanhMuc"]))?Guid.Empty:(System.Guid)row["ID_SanPhamDanhMuc"];
					c.TenSanPham = (Convert.IsDBNull(row["TenSanPham"]))?string.Empty:(System.String)row["TenSanPham"];
					c.MoTaSanPham = (Convert.IsDBNull(row["MoTaSanPham"]))?string.Empty:(System.String)row["MoTaSanPham"];
					c.NhaSanXuat = (Convert.IsDBNull(row["NhaSanXuat"]))?string.Empty:(System.String)row["NhaSanXuat"];
					c.DonViTinh = (Convert.IsDBNull(row["DonViTinh"]))?string.Empty:(System.String)row["DonViTinh"];
					c.HinhMinhHoa = (Convert.IsDBNull(row["HinhMinhHoa"]))?string.Empty:(System.String)row["HinhMinhHoa"];
					c.TrangThaiSanPham = (Convert.IsDBNull(row["TrangThaiSanPham"]))?false:(System.Boolean)row["TrangThaiSanPham"];
					c.SoLanXem = (Convert.IsDBNull(row["SoLanXem"]))?(long)0:(System.Int64)row["SoLanXem"];
					c.TenSanPhamDanhMuc = (Convert.IsDBNull(row["TenSanPhamDanhMuc"]))?string.Empty:(System.String)row["TenSanPhamDanhMuc"];
					c.MoTaSanPhamDanhMuc = (Convert.IsDBNull(row["MoTaSanPhamDanhMuc"]))?string.Empty:(System.String)row["MoTaSanPhamDanhMuc"];
					c.HinhMinhHoaSanPhamDanhMuc = (Convert.IsDBNull(row["HinhMinhHoaSanPhamDanhMuc"]))?string.Empty:(System.String)row["HinhMinhHoaSanPhamDanhMuc"];
					c.KeyBangGia = (Convert.IsDBNull(row["KeyBangGia"]))?Guid.Empty:(System.Guid)row["KeyBangGia"];
					c.AcceptChanges();
					rows.Add(c);
					pagelen -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		*/	
						
		///<summary>
		/// Fill an <see cref="VList&lt;ViewBangGiaSanPham&gt;"/> From a DataReader.
		///</summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pageLength">number of row.</param>
		///<returns>a <see cref="VList&lt;ViewBangGiaSanPham&gt;"/></returns>
		protected VList<ViewBangGiaSanPham> Fill(IDataReader reader, VList<ViewBangGiaSanPham> rows, int start, int pageLength)
		{
			int recordnum = 0;
			while (reader.Read() && (pageLength != 0))
			{
				if(recordnum >= start)
				{
					ViewBangGiaSanPham entity = null;
					if (DataRepository.Provider.UseEntityFactory)
					{
						entity = EntityManager.CreateViewEntity<ViewBangGiaSanPham>("ViewBangGiaSanPham",  DataRepository.Provider.EntityCreationalFactoryType); 
					}
					else
					{
						entity = new ViewBangGiaSanPham();
					}
					entity.IDSanPham = (System.Guid)reader["ID_SanPham"];
					//entity.IDSanPham = (Convert.IsDBNull(reader["ID_SanPham"]))?Guid.Empty:(System.Guid)reader["ID_SanPham"];
					entity.IDNhaCungCap = (System.Guid)reader["ID_NhaCungCap"];
					//entity.IDNhaCungCap = (Convert.IsDBNull(reader["ID_NhaCungCap"]))?Guid.Empty:(System.Guid)reader["ID_NhaCungCap"];
					entity.IDDiaBan = (System.Guid)reader["ID_DiaBan"];
					//entity.IDDiaBan = (Convert.IsDBNull(reader["ID_DiaBan"]))?Guid.Empty:(System.Guid)reader["ID_DiaBan"];
					entity.KichHoat = (System.Boolean)reader["KichHoat"];
					//entity.KichHoat = (Convert.IsDBNull(reader["KichHoat"]))?false:(System.Boolean)reader["KichHoat"];
					entity.ChungThuc = (System.Boolean)reader["ChungThuc"];
					//entity.ChungThuc = (Convert.IsDBNull(reader["ChungThuc"]))?false:(System.Boolean)reader["ChungThuc"];
					entity.TrangThai = (System.Boolean)reader["TrangThai"];
					//entity.TrangThai = (Convert.IsDBNull(reader["TrangThai"]))?false:(System.Boolean)reader["TrangThai"];
					entity.ChoNhapGia = (System.Boolean)reader["ChoNhapGia"];
					//entity.ChoNhapGia = (Convert.IsDBNull(reader["ChoNhapGia"]))?false:(System.Boolean)reader["ChoNhapGia"];
					entity.DonGia = (System.Decimal)reader["DonGia"];
					//entity.DonGia = (Convert.IsDBNull(reader["DonGia"]))?0:(System.Decimal)reader["DonGia"];
					entity.VAT = (System.Double)reader["VAT"];
					//entity.VAT = (Convert.IsDBNull(reader["VAT"]))?0.0f:(System.Double)reader["VAT"];
					entity.SoLuongTrongKho = reader.IsDBNull(reader.GetOrdinal("SoLuongTrongKho")) ? null : (System.Int64?)reader["SoLuongTrongKho"];
					//entity.SoLuongTrongKho = (Convert.IsDBNull(reader["SoLuongTrongKho"]))?(long)0:(System.Int64?)reader["SoLuongTrongKho"];
					entity.TieuChuanKyThuat = reader.IsDBNull(reader.GetOrdinal("TieuChuanKyThuat")) ? null : (System.String)reader["TieuChuanKyThuat"];
					//entity.TieuChuanKyThuat = (Convert.IsDBNull(reader["TieuChuanKyThuat"]))?string.Empty:(System.String)reader["TieuChuanKyThuat"];
					entity.Thongtinthem = reader.IsDBNull(reader.GetOrdinal("Thongtinthem")) ? null : (System.String)reader["Thongtinthem"];
					//entity.Thongtinthem = (Convert.IsDBNull(reader["Thongtinthem"]))?string.Empty:(System.String)reader["Thongtinthem"];
					entity.ThoiDiemDangBaoGia = (System.DateTime)reader["ThoiDiemDangBaoGia"];
					//entity.ThoiDiemDangBaoGia = (Convert.IsDBNull(reader["ThoiDiemDangBaoGia"]))?DateTime.MinValue:(System.DateTime)reader["ThoiDiemDangBaoGia"];
					entity.ThoiDiemHetHieuLuc = (System.DateTime)reader["ThoiDiemHetHieuLuc"];
					//entity.ThoiDiemHetHieuLuc = (Convert.IsDBNull(reader["ThoiDiemHetHieuLuc"]))?DateTime.MinValue:(System.DateTime)reader["ThoiDiemHetHieuLuc"];
					entity.NgoaiTe = (System.String)reader["NgoaiTe"];
					//entity.NgoaiTe = (Convert.IsDBNull(reader["NgoaiTe"]))?string.Empty:(System.String)reader["NgoaiTe"];
					entity.TenNgoaiTe = (System.String)reader["TenNgoaiTe"];
					//entity.TenNgoaiTe = (Convert.IsDBNull(reader["TenNgoaiTe"]))?string.Empty:(System.String)reader["TenNgoaiTe"];
					entity.TyGia = (System.Double)reader["TyGia"];
					//entity.TyGia = (Convert.IsDBNull(reader["TyGia"]))?0.0f:(System.Double)reader["TyGia"];
					entity.MaDiaBan = (System.String)reader["MaDiaBan"];
					//entity.MaDiaBan = (Convert.IsDBNull(reader["MaDiaBan"]))?string.Empty:(System.String)reader["MaDiaBan"];
					entity.NhaCungCap = (System.String)reader["NhaCungCap"];
					//entity.NhaCungCap = (Convert.IsDBNull(reader["NhaCungCap"]))?string.Empty:(System.String)reader["NhaCungCap"];
					entity.TenNhaCungCap = (System.String)reader["TenNhaCungCap"];
					//entity.TenNhaCungCap = (Convert.IsDBNull(reader["TenNhaCungCap"]))?string.Empty:(System.String)reader["TenNhaCungCap"];
					entity.IDSanPhamDanhMuc = (System.Guid)reader["ID_SanPhamDanhMuc"];
					//entity.IDSanPhamDanhMuc = (Convert.IsDBNull(reader["ID_SanPhamDanhMuc"]))?Guid.Empty:(System.Guid)reader["ID_SanPhamDanhMuc"];
					entity.TenSanPham = (System.String)reader["TenSanPham"];
					//entity.TenSanPham = (Convert.IsDBNull(reader["TenSanPham"]))?string.Empty:(System.String)reader["TenSanPham"];
					entity.MoTaSanPham = reader.IsDBNull(reader.GetOrdinal("MoTaSanPham")) ? null : (System.String)reader["MoTaSanPham"];
					//entity.MoTaSanPham = (Convert.IsDBNull(reader["MoTaSanPham"]))?string.Empty:(System.String)reader["MoTaSanPham"];
					entity.NhaSanXuat = reader.IsDBNull(reader.GetOrdinal("NhaSanXuat")) ? null : (System.String)reader["NhaSanXuat"];
					//entity.NhaSanXuat = (Convert.IsDBNull(reader["NhaSanXuat"]))?string.Empty:(System.String)reader["NhaSanXuat"];
					entity.DonViTinh = reader.IsDBNull(reader.GetOrdinal("DonViTinh")) ? null : (System.String)reader["DonViTinh"];
					//entity.DonViTinh = (Convert.IsDBNull(reader["DonViTinh"]))?string.Empty:(System.String)reader["DonViTinh"];
					entity.HinhMinhHoa = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoa")) ? null : (System.String)reader["HinhMinhHoa"];
					//entity.HinhMinhHoa = (Convert.IsDBNull(reader["HinhMinhHoa"]))?string.Empty:(System.String)reader["HinhMinhHoa"];
					entity.TrangThaiSanPham = (System.Boolean)reader["TrangThaiSanPham"];
					//entity.TrangThaiSanPham = (Convert.IsDBNull(reader["TrangThaiSanPham"]))?false:(System.Boolean)reader["TrangThaiSanPham"];
					entity.SoLanXem = (System.Int64)reader["SoLanXem"];
					//entity.SoLanXem = (Convert.IsDBNull(reader["SoLanXem"]))?(long)0:(System.Int64)reader["SoLanXem"];
					entity.TenSanPhamDanhMuc = (System.String)reader["TenSanPhamDanhMuc"];
					//entity.TenSanPhamDanhMuc = (Convert.IsDBNull(reader["TenSanPhamDanhMuc"]))?string.Empty:(System.String)reader["TenSanPhamDanhMuc"];
					entity.MoTaSanPhamDanhMuc = reader.IsDBNull(reader.GetOrdinal("MoTaSanPhamDanhMuc")) ? null : (System.String)reader["MoTaSanPhamDanhMuc"];
					//entity.MoTaSanPhamDanhMuc = (Convert.IsDBNull(reader["MoTaSanPhamDanhMuc"]))?string.Empty:(System.String)reader["MoTaSanPhamDanhMuc"];
					entity.HinhMinhHoaSanPhamDanhMuc = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoaSanPhamDanhMuc")) ? null : (System.String)reader["HinhMinhHoaSanPhamDanhMuc"];
					//entity.HinhMinhHoaSanPhamDanhMuc = (Convert.IsDBNull(reader["HinhMinhHoaSanPhamDanhMuc"]))?string.Empty:(System.String)reader["HinhMinhHoaSanPhamDanhMuc"];
					entity.KeyBangGia = (System.Guid)reader["KeyBangGia"];
					//entity.KeyBangGia = (Convert.IsDBNull(reader["KeyBangGia"]))?Guid.Empty:(System.Guid)reader["KeyBangGia"];
					entity.AcceptChanges();
					rows.Add(entity);
					pageLength -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		
		
		/// <summary>
		/// Refreshes the <see cref="ViewBangGiaSanPham"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="ViewBangGiaSanPham"/> object to refresh.</param>
		protected void RefreshEntity(IDataReader reader, ViewBangGiaSanPham entity)
		{
			reader.Read();
			entity.IDSanPham = (System.Guid)reader["ID_SanPham"];
			//entity.IDSanPham = (Convert.IsDBNull(reader["ID_SanPham"]))?Guid.Empty:(System.Guid)reader["ID_SanPham"];
			entity.IDNhaCungCap = (System.Guid)reader["ID_NhaCungCap"];
			//entity.IDNhaCungCap = (Convert.IsDBNull(reader["ID_NhaCungCap"]))?Guid.Empty:(System.Guid)reader["ID_NhaCungCap"];
			entity.IDDiaBan = (System.Guid)reader["ID_DiaBan"];
			//entity.IDDiaBan = (Convert.IsDBNull(reader["ID_DiaBan"]))?Guid.Empty:(System.Guid)reader["ID_DiaBan"];
			entity.KichHoat = (System.Boolean)reader["KichHoat"];
			//entity.KichHoat = (Convert.IsDBNull(reader["KichHoat"]))?false:(System.Boolean)reader["KichHoat"];
			entity.ChungThuc = (System.Boolean)reader["ChungThuc"];
			//entity.ChungThuc = (Convert.IsDBNull(reader["ChungThuc"]))?false:(System.Boolean)reader["ChungThuc"];
			entity.TrangThai = (System.Boolean)reader["TrangThai"];
			//entity.TrangThai = (Convert.IsDBNull(reader["TrangThai"]))?false:(System.Boolean)reader["TrangThai"];
			entity.ChoNhapGia = (System.Boolean)reader["ChoNhapGia"];
			//entity.ChoNhapGia = (Convert.IsDBNull(reader["ChoNhapGia"]))?false:(System.Boolean)reader["ChoNhapGia"];
			entity.DonGia = (System.Decimal)reader["DonGia"];
			//entity.DonGia = (Convert.IsDBNull(reader["DonGia"]))?0:(System.Decimal)reader["DonGia"];
			entity.VAT = (System.Double)reader["VAT"];
			//entity.VAT = (Convert.IsDBNull(reader["VAT"]))?0.0f:(System.Double)reader["VAT"];
			entity.SoLuongTrongKho = reader.IsDBNull(reader.GetOrdinal("SoLuongTrongKho")) ? null : (System.Int64?)reader["SoLuongTrongKho"];
			//entity.SoLuongTrongKho = (Convert.IsDBNull(reader["SoLuongTrongKho"]))?(long)0:(System.Int64?)reader["SoLuongTrongKho"];
			entity.TieuChuanKyThuat = reader.IsDBNull(reader.GetOrdinal("TieuChuanKyThuat")) ? null : (System.String)reader["TieuChuanKyThuat"];
			//entity.TieuChuanKyThuat = (Convert.IsDBNull(reader["TieuChuanKyThuat"]))?string.Empty:(System.String)reader["TieuChuanKyThuat"];
			entity.Thongtinthem = reader.IsDBNull(reader.GetOrdinal("Thongtinthem")) ? null : (System.String)reader["Thongtinthem"];
			//entity.Thongtinthem = (Convert.IsDBNull(reader["Thongtinthem"]))?string.Empty:(System.String)reader["Thongtinthem"];
			entity.ThoiDiemDangBaoGia = (System.DateTime)reader["ThoiDiemDangBaoGia"];
			//entity.ThoiDiemDangBaoGia = (Convert.IsDBNull(reader["ThoiDiemDangBaoGia"]))?DateTime.MinValue:(System.DateTime)reader["ThoiDiemDangBaoGia"];
			entity.ThoiDiemHetHieuLuc = (System.DateTime)reader["ThoiDiemHetHieuLuc"];
			//entity.ThoiDiemHetHieuLuc = (Convert.IsDBNull(reader["ThoiDiemHetHieuLuc"]))?DateTime.MinValue:(System.DateTime)reader["ThoiDiemHetHieuLuc"];
			entity.NgoaiTe = (System.String)reader["NgoaiTe"];
			//entity.NgoaiTe = (Convert.IsDBNull(reader["NgoaiTe"]))?string.Empty:(System.String)reader["NgoaiTe"];
			entity.TenNgoaiTe = (System.String)reader["TenNgoaiTe"];
			//entity.TenNgoaiTe = (Convert.IsDBNull(reader["TenNgoaiTe"]))?string.Empty:(System.String)reader["TenNgoaiTe"];
			entity.TyGia = (System.Double)reader["TyGia"];
			//entity.TyGia = (Convert.IsDBNull(reader["TyGia"]))?0.0f:(System.Double)reader["TyGia"];
			entity.MaDiaBan = (System.String)reader["MaDiaBan"];
			//entity.MaDiaBan = (Convert.IsDBNull(reader["MaDiaBan"]))?string.Empty:(System.String)reader["MaDiaBan"];
			entity.NhaCungCap = (System.String)reader["NhaCungCap"];
			//entity.NhaCungCap = (Convert.IsDBNull(reader["NhaCungCap"]))?string.Empty:(System.String)reader["NhaCungCap"];
			entity.TenNhaCungCap = (System.String)reader["TenNhaCungCap"];
			//entity.TenNhaCungCap = (Convert.IsDBNull(reader["TenNhaCungCap"]))?string.Empty:(System.String)reader["TenNhaCungCap"];
			entity.IDSanPhamDanhMuc = (System.Guid)reader["ID_SanPhamDanhMuc"];
			//entity.IDSanPhamDanhMuc = (Convert.IsDBNull(reader["ID_SanPhamDanhMuc"]))?Guid.Empty:(System.Guid)reader["ID_SanPhamDanhMuc"];
			entity.TenSanPham = (System.String)reader["TenSanPham"];
			//entity.TenSanPham = (Convert.IsDBNull(reader["TenSanPham"]))?string.Empty:(System.String)reader["TenSanPham"];
			entity.MoTaSanPham = reader.IsDBNull(reader.GetOrdinal("MoTaSanPham")) ? null : (System.String)reader["MoTaSanPham"];
			//entity.MoTaSanPham = (Convert.IsDBNull(reader["MoTaSanPham"]))?string.Empty:(System.String)reader["MoTaSanPham"];
			entity.NhaSanXuat = reader.IsDBNull(reader.GetOrdinal("NhaSanXuat")) ? null : (System.String)reader["NhaSanXuat"];
			//entity.NhaSanXuat = (Convert.IsDBNull(reader["NhaSanXuat"]))?string.Empty:(System.String)reader["NhaSanXuat"];
			entity.DonViTinh = reader.IsDBNull(reader.GetOrdinal("DonViTinh")) ? null : (System.String)reader["DonViTinh"];
			//entity.DonViTinh = (Convert.IsDBNull(reader["DonViTinh"]))?string.Empty:(System.String)reader["DonViTinh"];
			entity.HinhMinhHoa = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoa")) ? null : (System.String)reader["HinhMinhHoa"];
			//entity.HinhMinhHoa = (Convert.IsDBNull(reader["HinhMinhHoa"]))?string.Empty:(System.String)reader["HinhMinhHoa"];
			entity.TrangThaiSanPham = (System.Boolean)reader["TrangThaiSanPham"];
			//entity.TrangThaiSanPham = (Convert.IsDBNull(reader["TrangThaiSanPham"]))?false:(System.Boolean)reader["TrangThaiSanPham"];
			entity.SoLanXem = (System.Int64)reader["SoLanXem"];
			//entity.SoLanXem = (Convert.IsDBNull(reader["SoLanXem"]))?(long)0:(System.Int64)reader["SoLanXem"];
			entity.TenSanPhamDanhMuc = (System.String)reader["TenSanPhamDanhMuc"];
			//entity.TenSanPhamDanhMuc = (Convert.IsDBNull(reader["TenSanPhamDanhMuc"]))?string.Empty:(System.String)reader["TenSanPhamDanhMuc"];
			entity.MoTaSanPhamDanhMuc = reader.IsDBNull(reader.GetOrdinal("MoTaSanPhamDanhMuc")) ? null : (System.String)reader["MoTaSanPhamDanhMuc"];
			//entity.MoTaSanPhamDanhMuc = (Convert.IsDBNull(reader["MoTaSanPhamDanhMuc"]))?string.Empty:(System.String)reader["MoTaSanPhamDanhMuc"];
			entity.HinhMinhHoaSanPhamDanhMuc = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoaSanPhamDanhMuc")) ? null : (System.String)reader["HinhMinhHoaSanPhamDanhMuc"];
			//entity.HinhMinhHoaSanPhamDanhMuc = (Convert.IsDBNull(reader["HinhMinhHoaSanPhamDanhMuc"]))?string.Empty:(System.String)reader["HinhMinhHoaSanPhamDanhMuc"];
			entity.KeyBangGia = (System.Guid)reader["KeyBangGia"];
			//entity.KeyBangGia = (Convert.IsDBNull(reader["KeyBangGia"]))?Guid.Empty:(System.Guid)reader["KeyBangGia"];
			reader.Close();
	
			entity.AcceptChanges();
		}
		
		/*
		/// <summary>
		/// Refreshes the <see cref="ViewBangGiaSanPham"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="ViewBangGiaSanPham"/> object.</param>
		protected static void RefreshEntity(DataSet dataSet, ViewBangGiaSanPham entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IDSanPham = (Convert.IsDBNull(dataRow["ID_SanPham"]))?Guid.Empty:(System.Guid)dataRow["ID_SanPham"];
			entity.IDNhaCungCap = (Convert.IsDBNull(dataRow["ID_NhaCungCap"]))?Guid.Empty:(System.Guid)dataRow["ID_NhaCungCap"];
			entity.IDDiaBan = (Convert.IsDBNull(dataRow["ID_DiaBan"]))?Guid.Empty:(System.Guid)dataRow["ID_DiaBan"];
			entity.KichHoat = (Convert.IsDBNull(dataRow["KichHoat"]))?false:(System.Boolean)dataRow["KichHoat"];
			entity.ChungThuc = (Convert.IsDBNull(dataRow["ChungThuc"]))?false:(System.Boolean)dataRow["ChungThuc"];
			entity.TrangThai = (Convert.IsDBNull(dataRow["TrangThai"]))?false:(System.Boolean)dataRow["TrangThai"];
			entity.ChoNhapGia = (Convert.IsDBNull(dataRow["ChoNhapGia"]))?false:(System.Boolean)dataRow["ChoNhapGia"];
			entity.DonGia = (Convert.IsDBNull(dataRow["DonGia"]))?0:(System.Decimal)dataRow["DonGia"];
			entity.VAT = (Convert.IsDBNull(dataRow["VAT"]))?0.0f:(System.Double)dataRow["VAT"];
			entity.SoLuongTrongKho = (Convert.IsDBNull(dataRow["SoLuongTrongKho"]))?(long)0:(System.Int64?)dataRow["SoLuongTrongKho"];
			entity.TieuChuanKyThuat = (Convert.IsDBNull(dataRow["TieuChuanKyThuat"]))?string.Empty:(System.String)dataRow["TieuChuanKyThuat"];
			entity.Thongtinthem = (Convert.IsDBNull(dataRow["Thongtinthem"]))?string.Empty:(System.String)dataRow["Thongtinthem"];
			entity.ThoiDiemDangBaoGia = (Convert.IsDBNull(dataRow["ThoiDiemDangBaoGia"]))?DateTime.MinValue:(System.DateTime)dataRow["ThoiDiemDangBaoGia"];
			entity.ThoiDiemHetHieuLuc = (Convert.IsDBNull(dataRow["ThoiDiemHetHieuLuc"]))?DateTime.MinValue:(System.DateTime)dataRow["ThoiDiemHetHieuLuc"];
			entity.NgoaiTe = (Convert.IsDBNull(dataRow["NgoaiTe"]))?string.Empty:(System.String)dataRow["NgoaiTe"];
			entity.TenNgoaiTe = (Convert.IsDBNull(dataRow["TenNgoaiTe"]))?string.Empty:(System.String)dataRow["TenNgoaiTe"];
			entity.TyGia = (Convert.IsDBNull(dataRow["TyGia"]))?0.0f:(System.Double)dataRow["TyGia"];
			entity.MaDiaBan = (Convert.IsDBNull(dataRow["MaDiaBan"]))?string.Empty:(System.String)dataRow["MaDiaBan"];
			entity.NhaCungCap = (Convert.IsDBNull(dataRow["NhaCungCap"]))?string.Empty:(System.String)dataRow["NhaCungCap"];
			entity.TenNhaCungCap = (Convert.IsDBNull(dataRow["TenNhaCungCap"]))?string.Empty:(System.String)dataRow["TenNhaCungCap"];
			entity.IDSanPhamDanhMuc = (Convert.IsDBNull(dataRow["ID_SanPhamDanhMuc"]))?Guid.Empty:(System.Guid)dataRow["ID_SanPhamDanhMuc"];
			entity.TenSanPham = (Convert.IsDBNull(dataRow["TenSanPham"]))?string.Empty:(System.String)dataRow["TenSanPham"];
			entity.MoTaSanPham = (Convert.IsDBNull(dataRow["MoTaSanPham"]))?string.Empty:(System.String)dataRow["MoTaSanPham"];
			entity.NhaSanXuat = (Convert.IsDBNull(dataRow["NhaSanXuat"]))?string.Empty:(System.String)dataRow["NhaSanXuat"];
			entity.DonViTinh = (Convert.IsDBNull(dataRow["DonViTinh"]))?string.Empty:(System.String)dataRow["DonViTinh"];
			entity.HinhMinhHoa = (Convert.IsDBNull(dataRow["HinhMinhHoa"]))?string.Empty:(System.String)dataRow["HinhMinhHoa"];
			entity.TrangThaiSanPham = (Convert.IsDBNull(dataRow["TrangThaiSanPham"]))?false:(System.Boolean)dataRow["TrangThaiSanPham"];
			entity.SoLanXem = (Convert.IsDBNull(dataRow["SoLanXem"]))?(long)0:(System.Int64)dataRow["SoLanXem"];
			entity.TenSanPhamDanhMuc = (Convert.IsDBNull(dataRow["TenSanPhamDanhMuc"]))?string.Empty:(System.String)dataRow["TenSanPhamDanhMuc"];
			entity.MoTaSanPhamDanhMuc = (Convert.IsDBNull(dataRow["MoTaSanPhamDanhMuc"]))?string.Empty:(System.String)dataRow["MoTaSanPhamDanhMuc"];
			entity.HinhMinhHoaSanPhamDanhMuc = (Convert.IsDBNull(dataRow["HinhMinhHoaSanPhamDanhMuc"]))?string.Empty:(System.String)dataRow["HinhMinhHoaSanPhamDanhMuc"];
			entity.KeyBangGia = (Convert.IsDBNull(dataRow["KeyBangGia"]))?Guid.Empty:(System.Guid)dataRow["KeyBangGia"];
			entity.AcceptChanges();
		}
		*/
			
		#endregion Helper Functions
	}//end class

	#region ViewBangGiaSanPhamFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ViewBangGiaSanPham"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ViewBangGiaSanPhamFilterBuilder : SqlFilterBuilder<ViewBangGiaSanPhamColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ViewBangGiaSanPhamFilterBuilder class.
		/// </summary>
		public ViewBangGiaSanPhamFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ViewBangGiaSanPhamFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ViewBangGiaSanPhamFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ViewBangGiaSanPhamFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ViewBangGiaSanPhamFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ViewBangGiaSanPhamFilterBuilder

	#region ViewBangGiaSanPhamParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ViewBangGiaSanPham"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ViewBangGiaSanPhamParameterBuilder : ParameterizedSqlFilterBuilder<ViewBangGiaSanPhamColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ViewBangGiaSanPhamParameterBuilder class.
		/// </summary>
		public ViewBangGiaSanPhamParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ViewBangGiaSanPhamParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ViewBangGiaSanPhamParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ViewBangGiaSanPhamParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ViewBangGiaSanPhamParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ViewBangGiaSanPhamParameterBuilder
} // end namespace
